package com.bs.bszhsq.utils;

import java.util.HashMap;

public class R extends HashMap {
    /**
     * 成功无返回数据
     * @return
     */
    public static R success(){
   R success = new R();
   success.put("code","200");
   success.put("msg","ok");
   return success;
    }

    /**
     * 成功，有返回数据
     * @param data
     * @return
     */
    public static R success(Object data) {
        R success = new R();
        success.put("code", "200");
        success.put("msg", "ok");
        success.put("data", data);
        return success;
    }
    /**
     * 错误有提示信息
     */
    public static R error(String msg) {
        R error = new R();
        error.put("code", "500");
        error.put("msg", msg);
        return error;
    }
    /**
     * 错误，无提示信息
     * @return
     */
    public static R error() {
        R error = new R();
        error.put("code", "500");
        return error;
    }

    public static R err() {
        R error = new R();
        error.put("code", "503");
        return error;
    }

    public static R write(Boolean flag){
        if (flag){
            return R.success();
        }else {
            return R.error("操作失败！！！");
        }
    }
}
